package com.zhongzhi.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zhongzhi.service.TypeService;
import com.zhongzhi.springboot.pojo.Computers;
import com.zhongzhi.springboot.pojo.Measure;
import com.zhongzhi.springboot.pojo.Type;
import com.zhongzhi.util.Bo;
import com.zhongzhi.util.JsonResult;
/**
 * 机型业务层
 * @author Administrator
 *
 */
@RestController
@RequestMapping("/type/")
public class TypeController {
	@Autowired
	private TypeService typeService;

	//增加机型
	@RequestMapping("insert")
	public JsonResult insert(Type type) {
		Bo bo = typeService.insert(type);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//修改机型
	@RequestMapping("update")
	public JsonResult update(Type type) {
		Bo bo = typeService.update(type);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}

	//删除机型(如果机型下面有测试数据,则不能删除)
	@RequestMapping("delete")
	public JsonResult delete(Integer id) {
		Bo bo = typeService.delete(id);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}

	//查询全部机型
	@RequestMapping("select")
	public JsonResult select(Integer pages,Integer line) {
		Bo bo = typeService.select(pages,line);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//查询全部机型总数
	@RequestMapping("selectSize")
	public JsonResult selectSize() {
		Bo bo = typeService.selectSize();
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}

	//根据id查询机型
	@RequestMapping("selectById")
	public JsonResult selectById(Integer id) {
		Bo bo = typeService.selectById(id);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}

	//根据id查询机型
	@RequestMapping("selectByNameSize")
	public JsonResult selectByNameSize(String typeName) {
		Bo bo = typeService.selectByNameSize(typeName);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//根据名称查询机型全部
	@RequestMapping("selectByName")
	public JsonResult selectByName(String typeName) {
		Bo bo = typeService.selectByName(typeName);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//8:增加计算机
	@RequestMapping("webinsert")
	public JsonResult webinsert(Type type) {
		Bo bo = typeService.webinsert(type);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//9:修改计算机
	@RequestMapping("webupdate")
	public JsonResult webupdate(Type type) {
		Bo bo = typeService.webupdate(type);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}

	//10:删除计算机(如果计算机有者通道,则不能删除)
	@RequestMapping("webdelete")
	public JsonResult webdelete(Integer id) {
		Bo bo = typeService.webdelete(id);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//11:查询全部计算机
	@RequestMapping("webselect")
	public JsonResult webselect() {
		Bo bo = typeService.webselect();
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}

}
